package net.xxcxcxcx.xc_enhancedmob.event;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.ActionResult;

/**
 * 发动攻击的事件
 */
public interface onStartAttackCallback {
    Event<onStartAttackCallback> EVENT = EventFactory.createArrayBacked(onStartAttackCallback.class,
            (listeners) -> (attacker, target) -> {
                for (onStartAttackCallback listener : listeners) {
                    ActionResult result = listener.onStartAttack(attacker, target);
                    if (result != ActionResult.PASS) {
                        return result;
                    }
                }
                return ActionResult.PASS;
            }
    );

    ActionResult onStartAttack(LivingEntity attacker, LivingEntity target);
}
